// 1. 引入和安装
import Vue from 'vue'
import VueI18n from 'vue-i18n'
Vue.use(VueI18n)

import Cookie from 'js-cookie'

// 引入饿了么语言包
import elementEN from 'element-ui/lib/locale/lang/en'
import elementZH from 'element-ui/lib/locale/lang/zh-CN'

// 引入自定义翻译包
import ZH from './locale/zh'
import EN from './locale/en'

// 2. 创建实例
export default new VueI18n({
  // 选项1 默认语言
  locale: Cookie.get('language') || 'zh',
  // 选项2 字典对象
  messages: {
    zh: {
      hello: '你好',
      ...elementZH,
      ...ZH
    },
    en: {
      hello: 'How are you',
      ...elementEN,
      ...EN
    }
  }
})
